package shapes;

import interfaces.IShape;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

/**********************************************
 * Cours :			LOG120
 * Session :		Automne 2011
 * Groupe : 		03
 * Projet : 		Lab 1
 * Étudiant(e)(s) : Garcia Carrasco, Maria
 * 					Bolduc, Andrew
 * Code(s) perm. :  GARM05559006
 * 					BOLA03098701
 * Professeur : 	Yannick Boucher
 * Chargé de labo:  Jonathan Simard
 * Nom du fichier : Shape.java
 * Date crée :      2011-09-20
 **********************************************
 * Historique des modifications
 **********************************************
 * 2011-09-20		Version initiale
 **********************************************
 *
 */

public class IShapeDecorator implements IShape {
	
	private IShape shape;

	public IShapeDecorator(IShape shape) {
		this.shape = shape;
	}
	
	/**
	 * @return
	 */
	public int getxCoord() {
		return shape.getxCoord();
	}
	
	/**
	 * @return
	 */
	public int getyCoord() {
		return shape.getyCoord();
	}
	
	/**
	 * @return
	 */
	public Color getColor() {
		return shape.getColor();
	}
	
	/**
	 * @return
	 */
	public String getShapeName() {
		return shape.getShapeName();
	}
	
	/**
	 * @return
	 */
	public int getShapeID() {
		return shape.getShapeID();
	}

	public void setxOrigin(int xOrigin) {
		shape.setxOrigin(xOrigin);
	}

	public void setyOrigin(int yOrigin) {
		shape.setyOrigin(yOrigin);
	}

	public void setColor(Color color) {
		shape.setColor(color);
	}

	public void setShapeName(String shapeName) {
		shape.setShapeName(shapeName);
	}

	public void setShapeID(int shapeID) {
		shape.setShapeID(shapeID);
	}

	public int getSecondX() {
		return shape.getSecondX();
	}

	public void setSecondX(int secondX) {
		shape.setSecondX(secondX);
	}

	public int getSecondY() {
		return shape.getSecondY();
	}

	public void setSecondY(int secondY) {
		shape.setSecondY(secondY);
	}
	
	/* (non-Javadoc)
	 * @see shapes.AbstractShape#draw(java.awt.Graphics)
	 */
	@Override
	public void draw(Graphics graphics) {
		shape.draw(graphics);
		
		Graphics2D g = (Graphics2D)graphics;
		float dash1[] = {1.0f};
		BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
		g.setColor(Color.BLACK);
		g.setStroke(dashed);
		
		System.out.println(shape.getShapeName());
		
		if(shape.getShapeName().equalsIgnoreCase(ShapeSettings.getRectangleName()) || shape.getShapeName().equalsIgnoreCase(ShapeSettings.getSquareName())) {
			g.drawRect(shape.getxCoord() - 1, shape.getyCoord() - 1, ((Rectangle) shape).getWidth() + 2, ((Rectangle) shape).getHeight() + 2);
		}
		else if(shape.getShapeName().equalsIgnoreCase(ShapeSettings.getOvalName()) || shape.getShapeName().equalsIgnoreCase(ShapeSettings.getCircleName())) {
			g.drawRect((shape.getxCoord() - (1/2)*shape.getSecondX()), (shape.getyCoord() - (1/2)*shape.getSecondY()), (shape.getSecondX()), (shape.getSecondY()));
		}
		else if(shape.getShapeName().equalsIgnoreCase(ShapeSettings.getLineName())) {
			//g.drawRect(shape.getxCoord(), shape.getyCoord(), Math.abs(shape.getSecondX() - shape.getxCoord()), Math.abs(shape.getSecondY() - shape.getyCoord()));
		}
	}

	@Override
	public float area() {
		return shape.area();
	}
	
	public IShape getShape() {
		return shape;
	}

	@Override
	public int getDistance() {
		return shape.getDistance();
	}
	
}